<?php
/**
 * OpenSSLによる復号化
 *
 * Copyright:2005/09/03, Adrian at http://jp2.php.net/manual/en/function.openssl-public-encrypt.php
 */
if(!function_exists('ssl_decrypt')){
    function ssl_decrypt($source,$type,$key){
        // The raw PHP decryption functions appear to work
        // on 128 Byte chunks. So this decrypts long text
        // encrypted with ssl_encrypt().

        $maxlength=128;
        $output='';
        while($source){
            $input= substr($source,0,$maxlength);
            $source=substr($source,$maxlength);
            if($type=='private'){
                $ok= openssl_private_decrypt($input,$out,$key);
            }else{
                $ok= openssl_public_decrypt($input,$out,$key);
            }

            $output.=$out;
        }

        return $output;

    }
}

?>